package com.example.task1.ui.AllService.parking;

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import com.example.task1.R;
import com.example.task1.bean.ParkingLotBean;
import com.example.task1.ui.BaseAdapter;

import java.util.ArrayList;
import java.util.List;

public class ParkingLotAdapter extends BaseAdapter<ParkingLotBean.RowsDTO> {

    private Context context;
    private List<ParkingLotBean.RowsDTO> mData = new ArrayList<>();
    private TextView tvName;
    private TextView tvPlateNumber;
    private TextView tvMonetary;
    private TextView tvParkNo;
    private TextView tvAddress;
    private TextView tvEntryTime;
    private TextView tvOutTime;

    public ParkingLotAdapter(Context context) {
        this.context = context;
    }

    @Override
    protected void setData(List<ParkingLotBean.RowsDTO> rows) {
        int size = mData.size();
        mData.addAll(rows);
        notifyItemInserted(size);
    }

    @Override
    protected int getLayout() {
        return R.layout.parkinglotlist;
    }

    @Override
    protected Context getContext() {
        return null;
    }

    @Override
    protected List<ParkingLotBean.RowsDTO> getData() {
        return mData;
    }

    @Override
    protected void onBind(myHolder holder, ParkingLotBean.RowsDTO date) {
        tvAddress.setText("停车场地址"+date.getAddress());
        tvEntryTime.setText("入场时间"+date.getAddress());
        tvMonetary.setText("消费金额"+date.getAddress());
        tvName.setText(date.getAddress());
        tvOutTime.setText("出场时间"+date.getAddress());
        tvParkNo.setText("车位号"+date.getAddress());
        tvPlateNumber.setText("车牌号"+date.getAddress());
    }

    @Override
    protected void holder(View view) {
        initView(view);
    }

    private void initView(View view) {
        tvName = view.findViewById(R.id.tv_name);
        tvPlateNumber = view.findViewById(R.id.tv_plateNumber);
        tvMonetary = view.findViewById(R.id.tv_monetary);
        tvParkNo = view.findViewById(R.id.tv_parkNo);
        tvAddress = view.findViewById(R.id.tv_address);
        tvEntryTime = view.findViewById(R.id.tv_entryTime);
        tvOutTime = view.findViewById(R.id.tv_outTime);
    }
}
